package com.woniuxy.life.filesystem.api.feign.fallback;

import com.woniuxy.life.core.api.CommonResult;
import com.woniuxy.life.filesystem.api.feign.RemoteMinIoUploadService;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

@Component
@Slf4j
@Setter
public class RemoteMinIoUploadServiceFallbackImpl implements RemoteMinIoUploadService {

    private Throwable cause;

    @Override
    public CommonResult upload(MultipartFile file) {
        log.error("feign 文件上传失败", cause);
        return CommonResult.failed("文件上传失败");
    }

    @Override
    public CommonResult delete(String objName) {
        log.error("feign 文件删除失败", cause);
        return CommonResult.failed("文件删除失败");
    }

    @Override
    public ResponseEntity download(String filename) {
        log.error("feign 文件下载失败", cause);
        return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
    }
}
